<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<gio-table-wrapper
  [disableSearchInput]="true"
  [disablePageSize]="false"
  [length]="total"
  [filters]="tableWrapperPagination"
  (filtersChange)="tableWrapperPaginationChange($event)"
>
  <table mat-table [dataSource]="deployments" aria-label="Direct members table" id="deploymentsTable" *ngIf="deployments">
    <!-- Version Column -->
    <ng-container matColumnDef="version">
      <th mat-header-cell *matHeaderCellDef>Version</th>
      <td mat-cell *matCellDef="let element">{{ element.properties[DEPLOYMENT_NUMBER_PROPERTY] }}</td>
    </ng-container>

    <!-- Date Column -->
    <ng-container matColumnDef="createdAt">
      <th mat-header-cell *matHeaderCellDef>Date</th>
      <td mat-cell *matCellDef="let element">{{ element.createdAt | date: 'medium' }}</td>
    </ng-container>

    <!-- User Column -->
    <ng-container matColumnDef="user">
      <th mat-header-cell *matHeaderCellDef>User</th>
      <td mat-cell *matCellDef="let element">{{ element.initiator.displayName }}</td>
    </ng-container>

    <!-- Label Column -->
    <ng-container matColumnDef="label">
      <th mat-header-cell *matHeaderCellDef>Label</th>
      <td mat-cell *matCellDef="let element">{{ element.properties[LABEL_PROPERTY] }}</td>
    </ng-container>

    <!-- Action Column -->
    <ng-container matColumnDef="action">
      <th mat-header-cell *matHeaderCellDef id="action">Action</th>
      <td mat-cell *matCellDef="let element">
        <div class="pre-wrapper">
          <div>
            <button
              mat-icon-button
              aria-label="Button to show version"
              matTooltip="Show version"
              routerLink="{{ element.id }}"
              id="actionButton"
            >
              <mat-icon svgIcon="gio:eye-empty"></mat-icon>
            </button>
          </div>
        </div>
      </td>
    </ng-container>

    <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
    <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>

    <!-- Row shown when there is no data -->
    <tr class="mat-mdc-row mdc-data-table__row" *matNoDataRow>
      <td *ngIf="deployments.length === 0" class="mat-mdc-cell mdc-data-table__cell" [attr.colspan]="displayedColumns.length">
        {{ 'There is no published API (yet).' }}
      </td>
    </tr>
  </table>
</gio-table-wrapper>
